package thinkingInJava;

public class Learn101 {
	public static class InsertClass{
		private Integer i=1;
	}
	void t3(){
		new InsertClass();
	}
	public static void main(String[] args) {
		t1();
	}

	public static void t1() {
		Outer outer = new Outer();
		Outer.Inner inner = outer.getInstance();
		// 这样new类部类对象
		Outer.Inner inner2 = outer.new Inner();
		inner.outer().outMethod();
		t2();
	}

	// 方法内的内部类
	public static void t2() {
		class MethodClass {
			private Integer i = 1;

			public Integer getI() {
				return i;
			}

			public void setI(Integer i) {
				this.i = i;
			}
		}
		System.out.println(new MethodClass().getI());

	}
}

class Outer {
	public void outMethod() {
		System.out.println("outMethod");
	}

	public class Inner {
		public Outer outer() {
			return Outer.this;
		}
	}

	public Inner getInstance() {
		return new Inner();
	}
}
